package app.auto.designer;

import android.app.LocalActivityManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;

import com.example.TestPlugin.asset.Apk;
import com.example.TestPlugin.asset.AssetCopyer;
import com.pgyersdk.crash.PgyCrashManager;
import com.pgyersdk.update.PgyUpdateManager;

import app.auto.designer.func.ExpActivity;
import app.auto.designer.tool.Util;
import app.auto.designer.view.ViewActivity;
import app.auto.runner.base.RRes;
import app.auto.runner.base.framework.CrashHandler;

import static android.view.ViewGroup.FOCUS_AFTER_DESCENDANTS;

public class TestActivity extends ActivityBase {
    String http = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
            "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" +
            "    android:layout_width=\"match_parent\"\n" +
            "    android:layout_height=\"match_parent\"\n" +
            "    android:orientation=\"vertical\">\n" +
            "\n" +
            "    <RelativeLayout\n" +
            "        android:layout_width=\"match_parent\"\n" +
            "        android:layout_height=\"48dip\"\n" +
            "        android:background=\"@color/theme_color\">\n" +
            "\n" +
            "        <TextView\n" +
            "            android:id=\"@+id/test\"\n" +
            "            android:layout_width=\"wrap_content\"\n" +
            "            android:layout_height=\"wrap_content\"\n" +
            "            android:layout_alignParentLeft=\"true\"\n" +
            "            android:layout_centerVertical=\"true\"\n" +
            "            android:layout_marginLeft=\"20dip\"\n" +
            "            android:text=\"测试\"\n" +
            "            android:textColor=\"@color/auto_white\"\n" +
            "            android:textSize=\"16dip\" />\n" +
            "\n" +
            "        <TextView\n" +
            "            android:id=\"@+id/save_back\"\n" +
            "            android:layout_width=\"wrap_content\"\n" +
            "            android:layout_height=\"wrap_content\"\n" +
            "            android:layout_alignParentRight=\"true\"\n" +
            "            android:layout_centerVertical=\"true\"\n" +
            "            android:layout_marginRight=\"20dip\"\n" +
            "            android:text=\"保存\"\n" +
            "            android:textColor=\"@color/auto_white\"\n" +
            "            android:textSize=\"16dip\" />\n" +
            "    </RelativeLayout>\n" +

//            "<LinearLayout \n" +
//            "    android:orientation=\"vertical\" android:layout_width=\"match_parent\"\n" +
//            "    android:layout_height=\"match_parent\">\n" +
//            "    <Button\n" +
////                        "        xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" +
//            "        android:id=\"@+id/attr_constant\"\n" +
//            "        android:layout_width=\"160dip\"\n" +
//            "        android:layout_height=\"160dip\"\n" +
//            "        android:layout_alignParentRight=\"true\"\n" +
//            "        android:layout_centerVertical=\"true\"\n" +
//            "        android:layout_marginRight=\"20dip\"\n" +
//            "        android:background=\"#000000\"\n" +
//            "        android:ellipsize=\"middle\"\n" +
//            "        android:gravity=\"left|center_vertical\"\n" +
//            "        android:lines=\"1\"\n" +
//            "        android:text=\"啦啦啦\"\n" +
//            "        android:paddingLeft=\"66dip\"\n" +
//            "        android:textColor=\"#ffffff\"\n" +
//            "        android:textSize=\"16dip\"\n" +
//            "\n" +
//            "        />\n" +
//            "<Button\n" +
////                        "        xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" +
//            "        android:id=\"@+id/attr_constant\"\n" +
//            "        android:layout_width=\"33dip\"\n" +
//            "        android:layout_height=\"33dip\"\n" +
//            "        android:layout_alignParentRight=\"true\"\n" +
//            "        android:layout_centerVertical=\"true\"\n" +
//            "        android:layout_marginRight=\"20dip\"\n" +
//            "        android:background=\"#000000\"\n" +
//            "        android:ellipsize=\"middle\"\n" +
//            "        android:gravity=\"left|center_vertical\"\n" +
//            "        android:lines=\"1\"\n" +
//            "        android:text=\"啦啦啦\"\n" +
//            "        android:paddingLeft=\"66dip\"\n" +
//            "        android:textColor=\"#ffffff\"\n" +
//            "        android:textSize=\"16dip\"\n" +
//            "\n" +
//            "        />\n" +
//            "</LinearLayout>\n";


            "\n" +
            "    <LinearLayout\n" +
            "\n" +
            "        android:layout_width=\"match_parent\"\n" +
            "        android:layout_height=\"match_parent\"\n" +
            "        android:orientation=\"vertical\"\n" +
            "        android:paddingLeft=\"20dip\"\n" +
            "        android:paddingRight=\"20dip\">\n" +
            "\n" +
            "        <EditText\n" +
            "            android:id=\"@+id/intfid\"\n" +
            "            android:layout_width=\"match_parent\"\n" +
            "            android:layout_height=\"wrap_content\"\n" +
            "            android:layout_marginTop=\"10dip\"\n" +
            "            android:hint=\"接口id\"\n" +
            "            android:textSize=\"18dip\"\n" +
            "            android:visibility=\"gone\" />\n" +
            "\n" +
            "        <RelativeLayout\n" +
            "            android:layout_width=\"match_parent\"\n" +
            "            android:layout_height=\"wrap_content\">\n" +
            "\n" +
            "            <Button\n" +
            "                android:id=\"@+id/domain\"\n" +
            "                android:layout_width=\"wrap_content\"\n" +
            "                android:layout_height=\"wrap_content\"\n" +
            "                android:layout_alignParentRight=\"true\"\n" +
            "                android:layout_centerVertical=\"true\"\n" +
            "                android:gravity=\"center\"\n" +
            "\n" +
            "                android:text=\"域名\"\n" +
            "                android:textSize=\"18dip\" />\n" +
            "\n" +
            "            <EditText\n" +
            "                android:id=\"@+id/url\"\n" +
            "                android:layout_width=\"match_parent\"\n" +
            "                android:layout_height=\"wrap_content\"\n" +
            "                android:layout_marginTop=\"10dip\"\n" +
            "                android:layout_toLeftOf=\"@+id/domain\"\n" +
            "                android:hint=\"输入访问url\"\n" +
            "                android:maxLines=\"2\"\n" +
            "                android:textSize=\"18dip\" />\n" +
            "        </RelativeLayout>\n" +
            "\n" +
            "        <EditText\n" +
            "            android:id=\"@+id/description\"\n" +
            "            android:layout_width=\"match_parent\"\n" +
            "            android:layout_height=\"wrap_content\"\n" +
            "            android:layout_marginTop=\"10dip\"\n" +
            "            android:hint=\"接口描述\"\n" +
            "            android:textSize=\"18dip\" />\n" +
            "\n" +
            "        <RelativeLayout\n" +
            "            android:layout_width=\"match_parent\"\n" +
            "            android:layout_height=\"wrap_content\">\n" +
            "\n" +
            "            <RadioGroup\n" +
            "                android:id=\"@+id/type\"\n" +
            "                android:layout_width=\"wrap_content\"\n" +
            "                android:layout_height=\"wrap_content\"\n" +
            "                android:layout_marginTop=\"15dip\">\n" +
            "\n" +
            "                <RadioButton\n" +
            "                    android:id=\"@+id/POST\"\n" +
            "                    android:layout_width=\"match_parent\"\n" +
            "                    android:layout_height=\"wrap_content\"\n" +
            "                    android:text=\"POST\"\n" +
            "                    android:textSize=\"18dip\" />\n" +
            "\n" +
            "                <RadioButton\n" +
            "                    android:id=\"@+id/GET\"\n" +
            "                    android:layout_width=\"match_parent\"\n" +
            "                    android:layout_height=\"wrap_content\"\n" +
            "                    android:text=\"GET\"\n" +
            "                    android:textSize=\"18dip\" />\n" +
            "\n" +
            "            </RadioGroup>\n" +
            "\n" +
            "            <!--<Button\n" +
            "                android:layout_toRightOf=\"@+id/type\"\n" +
            "                android:id=\"@+id/del\"\n" +
            "                android:layout_width=\"wrap_content\"\n" +
            "                android:layout_height=\"wrap_content\"\n" +
            "                android:text=\"删除\"\n" +
            "                android:textColor=\"@color/auto_white\" />-->\n" +
            "        </RelativeLayout>\n" +
            "\n" +
            "        <RelativeLayout\n" +
            "            android:layout_width=\"match_parent\"\n" +
            "            android:layout_height=\"match_parent\"\n" +
            "            android:layout_marginTop=\"10dip\">\n" +
            "\n" +
            "            <Button\n" +
            "                android:id=\"@+id/addope\"\n" +
            "                android:layout_width=\"match_parent\"\n" +
            "                android:layout_height=\"wrap_content\"\n" +
            "                android:layout_alignParentBottom=\"true\"\n" +
            "                android:layout_marginBottom=\"15dip\"\n" +
            "                android:layout_marginTop=\"20dip\"\n" +
            "                android:gravity=\"center\"\n" +
            "                android:padding=\"15dip\"\n" +
            "                android:text=\"+\"\n" +
            "\n" +
            "                android:textStyle=\"bold\" />\n" +
            "\n" +
            "            <ListView\n" +
            "                android:id=\"@+id/param\"\n" +
            "                android:layout_width=\"match_parent\"\n" +
            "                android:layout_height=\"wrap_content\"\n" +
            "                android:layout_above=\"@+id/addope\"\n" +
            "                android:layout_alignParentTop=\"true\"\n" +
            "                android:cacheColorHint=\"@android:color/transparent\"\n" +
            "                android:footerDividersEnabled=\"true\"\n" +
            "                android:scrollbars=\"none\" />\n" +
            "        </RelativeLayout>\n" +
            "\n" +
            "    </LinearLayout>\n" +
            "\n" +
            "</LinearLayout>";



    //新建 打开
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        PgyCrashManager.register(this);
        PgyUpdateManager.register(this);
        CrashHandler.getInstance().init(this);
        setContentView(R.layout.activity_auto_test);


//        Apk.startApk(this,"","");
        RRes.initR("app.auto.designer");
        Util.init(this);
        getView(R.id.test).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(v.getContext(), ExpActivity.class));
            }
        });
        getView(R.id.test2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String stringreader = new String("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
                        "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" +
                        "    android:orientation=\"vertical\" android:layout_width=\"match_parent\"\n" +
                        "    android:layout_height=\"match_parent\">\n" +
                        "    <Button\n" +
//                        "        xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" +
                        "        android:id=\"@+id/attr_constant\"\n" +
                        "        android:layout_width=\"160dip\"\n" +
                        "        android:layout_height=\"160dip\"\n" +
                        "        android:layout_alignParentRight=\"true\"\n" +
                        "        android:layout_centerVertical=\"true\"\n" +
                        "        android:layout_marginRight=\"20dip\"\n" +
                        "        android:background=\"#000000\"\n" +
                        "        android:ellipsize=\"middle\"\n" +
                        "        android:gravity=\"left|center_vertical\"\n" +
                        "        android:lines=\"1\"\n" +
                        "        android:text=\"啦啦啦\"\n" +
                        "        android:paddingLeft=\"66dip\"\n" +
                        "        android:textColor=\"#ffffff\"\n" +
                        "        android:textSize=\"16dip\"\n" +
                        "\n" +
                        "        />\n" +
                        "<Button\n" +
//                        "        xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" +
                        "        android:id=\"@+id/attr_constant\"\n" +
                        "        android:layout_width=\"33dip\"\n" +
                        "        android:layout_height=\"33dip\"\n" +
                        "        android:layout_alignParentRight=\"true\"\n" +
                        "        android:layout_centerVertical=\"true\"\n" +
                        "        android:layout_marginRight=\"20dip\"\n" +
                        "        android:background=\"#000000\"\n" +
                        "        android:ellipsize=\"middle\"\n" +
                        "        android:gravity=\"left|center_vertical\"\n" +
                        "        android:lines=\"1\"\n" +
                        "        android:text=\"啦啦啦\"\n" +
                        "        android:paddingLeft=\"66dip\"\n" +
                        "        android:textColor=\"#ffffff\"\n" +
                        "        android:textSize=\"16dip\"\n" +
                        "\n" +
                        "        />\n" +
                        "</LinearLayout>\n"
                );
                startActivity(new Intent(v.getContext(), ViewActivity.class).putExtra("stringcontent", http));


            }
        });
//        getView(R.id.test2).performClick();
//        finish();
    }

}
